home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: line_parent.java,v 1.11 1996/10/03 19:46:51 hudson Exp $
- * $Author: hudson $
- */
-
- package sub_arctic.test;
-
- import sub_arctic.lib.interactor_applet;
- import sub_arctic.lib.line_display;
- import sub_arctic.output.drawable;
- import sub_arctic.input.simple_draggable;
- import sub_arctic.input.event;
- import sub_arctic.input.pressable;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.base_interactor;
-
- public class line_parent
- extends base_interactor implements pressable, simple_draggable {
- public line_parent()
- {
- super(0,0);
- /* make us able to be a parent */
- setup_for_children(10);
- /* we assume the parent will constrain us to fit in the UI */
- arrowheads=1;
- }
- public boolean press(event e, Object ui) {
- /* make us the drag focus */
- manager.simple_drag_focus.set_focus_to(this,e,new line_parent_status());
- return true;
- }
- public boolean release(event e, Object ui) {
- /* can't do anything, the focus overrides this and this doesn't
- get called*/
- return false;
- }
- /* just stash where the original point was */
- public boolean drag_start(event e, Object ui){
- line_parent_status stat = (line_parent_status)ui;
- stat.x_start=e.local_x();
- stat.y_start=e.local_y();
- stat.the_line = new line_display(stat.x_start, stat.y_start,
- stat.x_start, stat.y_start, arrowheads, angle, length);
- add_child(stat.the_line);
- return true;
- }
- public boolean drag_feedback(event evt, Object ui) {
- line_parent_status stat = (line_parent_status)ui;
- /* reset the coords to reflect this drag */
- stat.the_line.set_coords(stat.x_start,stat.y_start,
- evt.local_x(),evt.local_y());
- return true;
- }
- public boolean drag_end(event evt, Object ui) {
- line_parent_status stat = (line_parent_status)ui;
- /* reset the coords to reflect the new endpoint */
- stat.the_line.set_coords(stat.x_start, stat.y_start,
- evt.local_x(),evt.local_y());
- damage_self();
- return true;
- }
- int arrowheads;
- public void set_arrow_heads(int a) {
- arrowheads=a;
- }
- int length;
- public void set_arrow_head_length(int l) {
- length=l;
- }
- int angle;
- public void set_arrow_head_angle(int a) {
- angle=a;
- }
- }
-
- /* "local" class to hold our state information during drag */
- class line_parent_status {
- line_display the_line;
- int x_start, y_start;
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-